using System;
using System.Collections.Specialized;
using App_Code.Controls;

namespace widgets.AlexaSiteStats
{
    public partial class WidgetsAlexaSiteStatsEdit : WidgetEditBase
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                StringDictionary settings = GetSettings();
                txtWebsite.Text = settings["websiteURL"];
                if (settings["Size"] != null)
                    ddlSize.Items.FindByValue(settings["Size"]).Selected = true;
            }
        }

        /// <summary>
        /// Saves this the basic widget settings such as the Title, Size, WebsiteURL.
        /// </summary>
        public override void Save()
        {
            StringDictionary settings = GetSettings();
            settings["Size"] = ddlSize.SelectedItem.Value;
            settings["websiteURL"] = txtWebsite.Text;
            SaveSettings(settings);
        }
    }
}